home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0195.lzh / AMOSLIST / text0029.txt < prev    next >
Encoding:
Text File  |  1995-02-01  |  1.3 KB  |  57 lines

  1. > >Just a quick question here.
  2. > >
  3. > >I want to be able to use the RND() function to create random numbers, yet
  4. > >have those "random" numbers the same under certain circumstances.  See, I
  5. > >want the user to be able to specify a "seed" number, so that inputting the
  6. > >same "seed" will provide the same results.  Should I use RANDOMIZE SEED??? 
  7. >   No - that won't work (although it's supposed to - bug #153).  You'll have
  8. > to use this random number routine:
  9.  
  10. [routine deleted]
  11.  
  12. >   --Andy Church
  13.  
  14. Well, to those of you who require seedable random numbers, here is
  15. how you do it, without requiring you to write your own RND function.
  16.  
  17. Simply use the AMOS RND function, but use a NEGATIVE
  18. number for the RND limit.
  19.  
  20. Thus:
  21.  
  22. For A = 1 to 10
  23.   Randomise 42
  24.   For B = 1 to 10
  25.     Print Rnd(100)
  26.   Next B
  27. Next A
  28.  
  29. will produce 10 sets of different random numbers, thus proving that
  30. RND in this case ignores the reseeding via Randomise.
  31.  
  32. However:
  33.  
  34. For A = 1 to 10
  35.   Randomise 42
  36.   For B = 1 to 10
  37.     Print Rnd(-100)
  38.   Next B
  39. Next A
  40.  
  41. will produce 10 sets of random numbers where each set has the
  42. SAME random numbers in the SAME sequence.
  43.  
  44. Don`t thank me, thank Europress. They told me this workaround,
  45. about the only bit of help they were regarding AMOS though.......
  46.  
  47. Hello 1995
  48.  
  49. Chris
  50. c.j.coulson@ncl.ac.uk
  51. A4000 expanding nicely
  52.  
  53.